using System;
using System.Collections.Specialized;
using System.IO;
using System.Net;
using System.Text;
using System.Web;

namespace OpenWaves.ActivityFeed.Web.Handler
{
    public class HttpResponseStub : HttpResponseBase, IDisposable
    {
        public HttpResponseStub(Stream outputStream)
        {
            this.outputStream = outputStream;
        }

        public override Encoding ContentEncoding { get; set; }

        public override bool BufferOutput { get; set; }

        public override string ContentType { get; set; }

        private readonly NameValueCollection headers = new WebHeaderCollection();

        public override NameValueCollection Headers
        {
            get { return this.headers; }
        }

        public override void AppendHeader(string name, string value)
        {
            this.headers.Add(name, value);
        }

        private readonly Stream outputStream;
        public override Stream OutputStream
        {
            get { return this.outputStream; }
        }

        public override int StatusCode { get; set; }

        public override void End()
        {
        }

        public override void Flush()
        {
        }

        protected virtual void Dispose(bool disposing)
        {
            if (disposing)
                this.outputStream.Dispose();
        }

        public void Dispose()
        {
            this.Dispose(true);
            GC.SuppressFinalize(this);
        }
    }
}